package com.gcl.rabbitmq.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitmqUtil {


    private static final String host = "127.0.0.1";

    private static final String username = "anoraker";

    private static final String password = "anoraker";


    public static Channel getRabbitmqChannel() throws IOException, TimeoutException {
        // 创建连接配置
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost(host);
        factory.setUsername(username);
        factory.setPassword(password);
        // 获取连接
        Connection connection = factory.newConnection();
        // 返回信道
        return connection.createChannel();
    }



}
